<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" th:href="@{'/js/ztree/zTreeStyle.css'}"/>
        <link href="https://cdn.bootcss.com/layer/2.1/skin/layer.css" rel="stylesheet">
        <link th:href="@{'/js/bootstrap-3.3.7-dist/css/bootstrap.min.css'}" rel="stylesheet">
        <link th:href="@{'/js/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css'}"
              rel="stylesheet">

        <script th:src="@{'/js/jquery/jquery-2.1.1.min.js'}"></script>
        <script th:src="@{'/js/ztree/jquery.ztree.all-3.5.min.js'}"></script>
        <script th:src="@{'/js/bootstrap-3.3.7-dist/js/bootstrap.js'}"></script>


        <!--
         String contextPath = servletContext.getContextPath();
          servletContext.setAttribute("proPath", contextPath);

          如果 配置了  server.servlet.context-path=/thy
             这行<script th:src="@{${application.proPath}+'/js/bootstrap-3.3.7-dist/js/bootstrap.js'}"></script>会变成下面
            <script src="/thy/thy/js/bootstrap-3.3.7-dist/js/bootstrap.js"></script>

                @{}取值本身就包含了 servlet.context-path内容
         -->
        <script th:src="@{'/js/bootstrap-3.3.7-dist/js/bootstrap.js'}"></script>
        <script src="https://cdn.bootcss.com/layer/2.1/layer.js"></script>
        <title>Title</title>
    </head>
    <body class="container">

        <div class="row">
            <div class="col-md-6">
                <p id="vs"></p>
            </div>
            <div class="col-md-6">div2</div>
        </div>


<div class="row">
    <div class="col-md-4">
        imgSrc <a th:href="@{/pic/show}" target="_blank">图片</a>
        <!-- 得到的是|<a href="/thy/pic/show" target="_blank">图片</a> -->
    </div>
    <div class="col-md-4">
        使用1-1 <a th:href="@{/pic/show(url=${imgSrc})}" target="_blank">图片</a>
        <!-- 得到的结果是 <a href="/thy/pic/show?url=1.jpg" target="_blank">图片</a> -->
        使用1-2 <a th:href="@{/pic/show(url=${imgSrc},id=12.png)}" target="_blank">图片</a>
        <!-- <a href="/thy/pic/show?url=1.jpg&amp;id=12.png" target="_blank">图片</a> -->
    </div>

    <div class="col-md-4">
        使用2 <a th:href="@{'/pic/show/'+${imgSrc}}" target="_blank">图片</a>
        <!-- 可以得到  <a href="/thy/pic/show/1.jpg" target="_blank">图片</a> -->
    </div>
</div>
    </body>
    <!--    <script th:inline="javascript">-->
<script>
    $(function () {
        //请求参数
        $.ajax({
            //请求方式
            type: "POST",
            //请求的媒体类型
            contentType: "application/json;charset=UTF-8",
            //请求地址|
            // url: "/hello",|如果配置了 server.servlet.context-path 就必须用@{}的形式访问了。
            url: "[[@{'/hello'}]]",
            //数据，json字符串
            // data : JSON.stringify(list),
            //请求成功
            success: function (result) {
                $("#vs").html(result.date);
                console.log(result);
            },
            //请求失败，包含具体的错误信息
            error: function (e) {
                console.log(e.status);
                console.log(e.responseText);
            }
        });
    });
</script>
</html>